package com.topscore.uke.mvp.model;

import com.topscore.uke.entities.TeamPerformanceListEntity;
import com.topscore.uke.mvp.contractors.GetTeamSalesListContractor;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.network.request.GetTeamSalesRequest;
import com.topscore.uke.network.retrofit.HandleErrorSubscriber;

import java.util.List;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by 71468 on 2017/10/20.
 */

public class GetTeamSalesListModel implements GetTeamSalesListContractor,GetTeamSalesListContractor.Model {
    private CallBack mCallBack;

    public GetTeamSalesListModel(CallBack callBack) {
        this.mCallBack = callBack;
    }

    @Override
    public void getSalesList(GetTeamSalesRequest request) {
        mService.getTeamSalesList(request)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .unsubscribeOn(Schedulers.io())
                .subscribe(new HandleErrorSubscriber<BaseResponse<List<TeamPerformanceListEntity>>>(mCallBack) {
                    @Override
                    public void onSuccess(BaseResponse<List<TeamPerformanceListEntity>> response) {
                        mCallBack.getDataSuccess(response);
                    }
                });
    }
}
